# -*- coding: utf-8 -*-

from PyQt5.QtGui import *
import sys
from PyQt5.QtWidgets import *


class QFont(QWidget):
    def __init__(self):
        super(QFont, self).__init__()
        self.setWindowTitle("QFontDialog 例子")

        layout = QVBoxLayout()
        self.fontBtn = QPushButton("choose font")
        self.fontBtn.clicked.connect(self.get_font)
        layout.addWidget(self.fontBtn)

        self.fontEdit = QLabel("TEST FONT")
        layout.addWidget(self.fontEdit)

        self.setLayout(layout)

    def get_font(self):
        font, ok = QFontDialog.getFont()
        # font，以及ok键的点击与否（True或False）
        print(font)
        print(ok)
        if ok:
            self.fontEdit.setFont(font)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    font = QFont()
    font.show()
    sys.exit(app.exec_())
